package com.saftalk.db.entity;

import java.util.Date;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;


@PersistenceCapable
public class User {

	
	@PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Long id;
		
	
	@Persistent
	private String email;
	
	@Persistent
	private String name;
	 
	@Persistent
	private String password;
	
	@Persistent
	private String generatedPassword;

    @Persistent
    private Long familyId;
    
    @Persistent
    private String phoneNumber;
    
    @Persistent
    private Boolean receiveSms;
    
    @Persistent 
    private Boolean isAdmin;
    
    @Persistent 
    private Boolean isSenior;
    
    @Persistent 
    private String photoId;
    
	@Persistent
	private Long lastSeen;
    
	public User(String email, String name, String password, String generatedPassword, long familyId) {
		this.name = name;
		this.password = password;
		this.email = email;
		this.familyId = familyId;
		this.photoId = null;
		this.lastSeen = new Date().getTime();
		this.isSenior = false;
		this.generatedPassword = generatedPassword;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}


	public String getPassword() {
		return password;
	}


	public void setPassword(String password) {
		this.password = password;
	}


	public long getFamilyId() {
		return familyId;
	}

	public void setFamilyId(long familyId) {
		this.familyId = familyId;
	}
	
	public void setAdmin(boolean isAdmin) {
		this.isAdmin = isAdmin;
	}
	
	public boolean isAdmin() {
		return this.isAdmin;
	}

	public String getPhoneNumber() {
		return phoneNumber;
	}
	
	public void setSenior(boolean isSenior) {
		this.isSenior = isSenior;
	}
	
	public boolean isSenior() {
			return this.isSenior;
	}


	public void setPhoneNumber(String phoneNumber) {
		this.phoneNumber = phoneNumber;
	}

	public Boolean isReceiveSms() {
		return receiveSms;
	}

	public void setReceiveSms(Boolean receiveSms) {
		this.receiveSms = receiveSms;
	}
	
	public String getPhotoId() {
		return photoId;
	}
	
	public void setPhotoId(String photoId) {
		this.photoId = photoId;
	}
	
	public Long getLastSeen() {
		if (lastSeen.equals(null))
		{
			return (long)0;
		}
		return lastSeen;
	}

	public void updateLastSeen() {
		this.lastSeen = new Date().getTime();
	}
	
	public String getGeneratedPassword() {
		return generatedPassword;
	}
	
	public String getEmail() {
		return email;
	}
	
	public void setEmail(String email) {
		this.email = email;
	}
    public void setGeneratedPassword(String generatedPassword) {
		this.generatedPassword = generatedPassword;
	}
    


}
